package com.example.reagent_management.ui.operatedialog.adapter

import android.annotation.SuppressLint
import androidx.recyclerview.widget.DiffUtil
import com.example.lib_base.adapter.BasePagingAdapter
import com.example.lib_base.utils.DateConvertUtils
import com.example.reagent_management.R
import com.example.reagent_management.room.entity.ReagentInformation

class StorePageAdapter : BasePagingAdapter<ReagentInformation>(diffCallBack) {

    companion object{
        val diffCallBack = object : DiffUtil.ItemCallback<ReagentInformation>(){
            override fun areItemsTheSame(
                oldItem: ReagentInformation,
                newItem: ReagentInformation
            ): Boolean {
                return oldItem.reagent_id == newItem.reagent_id
            }

            @SuppressLint("DiffUtilEquals")
            override fun areContentsTheSame(
                oldItem: ReagentInformation,
                newItem: ReagentInformation
            ): Boolean {
                return oldItem == newItem
            }

        }
    }

    override fun getItemLayout(position: Int): Int {
        return R.layout.item_store
    }

    override fun bindData(helper: ItemHelper, data: ReagentInformation?) {
        helper.apply {
            setText(R.id.project_name,data?.projectName)
            setText(R.id.reagent_names,data?.reagentName)
            setText(R.id.type,data?.reagentType)
            setText(R.id.date,
                data?.createTime?.let { DateConvertUtils.convertTimeToStringCH(it.timeInMillis,"yyyy-MM-dd HH:mm:ss") })
        }
    }

    override fun getClickViewId(): Array<Int>? {
        return null
    }
}